﻿@{
    Layout = null;
}
@using Kevin.Shop.Business.Service.Entity.Helper
@model RiderShop.Mobile.Modle.MyAccount.MyPromotionCodeModel

<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/Themes/RongJi/Style/plugins/bootflat-2.0.3/css/site.min.css">
    <link rel="stylesheet" href="/Themes/RongJi/Style/base/css/common.css?v=3">
    <link rel="stylesheet" href="/Themes/Common/assert/plugins/sweetalert-1.0/lib/sweet-alert.css">
    <title>蓉记鲜鲜鲜大促优惠券</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="蓉记鲜鲜鲜，健康生活品质专家">
    <meta name="keywords" content="生鲜,美食,美酒,食材,菜谱,健康,蓉记,农产品,农产品电商,水果,蔬菜,虾,鱼,蟹,大闸蟹,海鲜,牛排,牛肉,肉,猪肉,特产,当季美食">
    <meta name="application-name" content="蓉记鲜鲜鲜">
    <meta name="msapplication-TileColor" content="#005A32">
    <link href="/Themes/RongJi/Style/v2.0/css/global.css" rel="stylesheet" />
    <!-- style -->
    <link href="/Themes/RongJi/Style/promotioncode/mianmo/style/css.css" rel="stylesheet" />

</head>
<body>
    <div class="single-groupon">
        <header class="single-groupon-header">
	    @if (@Model.PromotionCodeInfo != null)
            {
	     
		    <a href="/Product/ProductDetail?prd=" + >
			<img src="/Themes/RongJi/Style/promotioncode/activity/20150722/@Html.Raw(@Request.QueryString["promotionCode"] + ".png")" />
		    </a>
	    
	    }
        </header>
        <div class="groupon-card">
            <div class="groupon-card-top"></div>
            <div class="groupon-card-body">
                <div class="groupon-val " style="background: url(/Themes/RongJi/Style/promotioncode/activity/20150722/@Html.Raw(@Request.QueryString["promotionCode"].Replace("A","").Replace("I","") + ".png")) no-repeat center center;"></div>
                <div class="get-now"></div>
               
                @if (@Model.PromotionCodeInfo != null)
                {
                    if (@Request.QueryString["promotionCode"] == "AQC39" || @Request.QueryString["promotionCode"] == "IQC39")
                    {
		                <p>@Model.PromotionCodeInfo.Description (促销和秒杀除外)</p>
                    }
                    else
                    {
                         <p>@Model.PromotionCodeInfo.Description</p>
                    }
                    if (@Request.QueryString["promotionCode"].IndexOf("I") > -1)
                    {
                         <p>有 效 期：2015-07-25 截止: 2015-07-30</p>
                    }
                     <input type="hidden" id="promotionCode" value="@Model.PromotionCodeInfo.PromotionCode">
                     <input type="hidden" id="currentUserId" value="@WebClientContext.Current.UserId">
                }
                <a href="javascript:void(0);" id="receivePromotionCode" class="go-get-now">立即领取</a>
            </div>
        </div>
    </div>



    <script src="~/Themes/RongJi/Style/base/js/jquery-1.10.1.min.js"></script>
    <script src="~/Utility/pages/jquery.cookie.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="~/Utility/pages/pg_common.js"></script>
    <script src="~/Utility/pages/pg_global.js"></script>
    <script>
        $(function () {
            function onBridgeReady() {
                WeixinJSBridge.call('hideOptionMenu');
            }

            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                onBridgeReady();
            }


            //领取优惠券
            $("#receivePromotionCode").click(function () {
                var promotionCode = $.trim($("#promotionCode").val());
                var currentUserId = $.trim($("#currentUserId").val());
                if (currentUserId <= 0) {
                    var returnUrl = "~/Promotion/PromotionCodeSpecialActivity?promotionCode=" + promotionCode;
                    window.location.href = "../Customer/Login?ReturnUrl=" + returnUrl;
                    return false;
                }
                var submitData = {
                    PromotionCode: promotionCode
                };

                $.ajax({
                    type: "POST",
                    data: submitData,
                    dataType: "JSON",
                    url: "/Promotion/ReceivePrmotionCode",
                    success: function (response) {
                        if (response.Status == false && response.ErrorMessage == 'noHasPromotionCode') {
                            alert('没有优惠码！');

                            return false;
                        }
                        else if (response.Status == true && response.ErrorMessage == 'receiveSuccessfully') {
                            alert('领取成功！');
                            window.location.href = "/myaccount/mypromotioncode?promotiontype=" + response.Tag;
                            return true;
                        }
                        else {
                            alert(response.ErrorMessage);
			                window.location.href = "/myaccount/mypromotioncode?promotiontype=" + response.Tag;
                            return false;
                        }
                    },
                    error: function (err) {
                        //alert('异常错误！');
                        return false;
                    }
                });
            });

            var postData = {
                "currentUrl": window.location.href.replace(window.location.hash, '')
            }
            $.post("/WeixinJsSdk/ConfigScriptJson", postData, function (wxConfig) {
                wxConfig.jsApiList.push("hideOptionMenu");
                wx.config(wxConfig);

                wx.ready(function () {
                    // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
                    var config = window.config;

                    wx.hideOptionMenu();
                });

                wx.error(function (res) {

                    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

                });
            });
        });
    </script>

        <!--Static Code Start-->
    <script type="text/javascript" src="http://js.tongji.linezing.com/3547905/tongji.js"></script>
    <script type="text/javascript">
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fd2c430d3acdc174f29f6feef73ea35fa' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <!-- Piwik -->
    <script type="text/javascript">
        var _paq = _paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function () {
            var u = "//analytics.it-hsmedia.com/";
            _paq.push(['setTrackerUrl', u + 'piwik.php']);
            _paq.push(['setSiteId', 2]);
            var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
            g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
        })();
    </script>
    <noscript>
        <p>
            <img src="//analytics.it-hsmedia.com/piwik.php?idsite=2" style="border: 0;" alt="" />
        </p>
    </noscript>
    <!-- End Piwik Code -->
    <!--Static Code End-->
</body>
</html>
